﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Threading.Tasks;
using Dapper;
using JX.Core;
using JX.Core.Entity;
using JX.Infrastructure.Common;

namespace JX.Dapper
{
	/// <summary>
	/// 数据库表：TransferLog 的仓储实现类.
	/// </summary>
	public partial class TransferLogRepositoryDapper : RepositoryDapper<TransferLogEntity>,ITransferLogRepositoryDapper
	{	
		/// <summary>
		/// 构造器注入
		/// </summary>
		public TransferLogRepositoryDapper(DapperDBContext Context, IDapperDBContextFactory dbContextFactory) : base(Context,dbContextFactory)
		{
		}
		
		#region 删除
		/// <summary>
		/// 通过主键删除
		/// </summary>
		/// <returns></returns>
		public virtual bool Delete(int? transferLogID)
		{
			string strSQL = "delete from TransferLog where " +
			
			"TransferLogID = @TransferLogID"; 
			
			var param = new DynamicParameters();
			param.Add("@TransferLogID", transferLogID);
			
			return _Context.Execute(strSQL, param) > 0;
		}
		/// <summary>
		/// 通过主键删除
		/// </summary>
		/// <returns></returns>
		public virtual async Task<bool> DeleteAsync(int? transferLogID)
		{
			string strSQL = "delete from TransferLog where " +
			
			"TransferLogID = @TransferLogID"; 
			
			var param = new DynamicParameters();
			param.Add("@TransferLogID", transferLogID);
			
			return await _Context.ExecuteAsync(strSQL, param) > 0;
		}
		#endregion
		
		#region 得到实体
		/// <summary>
		/// 通过主键返回第一条信息的实体类。
		/// </summary>
		/// <returns></returns>
		public virtual TransferLogEntity Get(int? transferLogID)
		{
			string strCondition = string.Empty;
			strCondition += " and TransferLogID = @TransferLogID";
			
			var param = new DynamicParameters();
			param.Add("@TransferLogID", transferLogID);
			
			return Get(strCondition,param);
		}
		/// <summary>
		/// 通过主键返回第一条信息的实体类。
		/// </summary>
		/// <returns></returns>
		public virtual async Task<TransferLogEntity> GetAsync(int? transferLogID)
		{
			string strCondition = string.Empty;
			strCondition += " and TransferLogID = @TransferLogID";
			
			var param = new DynamicParameters();
			param.Add("@TransferLogID", transferLogID);
			
			return await GetAsync(strCondition,param);
		}
		#endregion
		
	}
}